package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
)

func main() {
	engine := gin.Default()

	engine.GET("/cookie", cookie)

	engine.Run()
}

//curl -H "Cookie: uid=zhangsan" "http://localhost:8080/cookie" -v
func cookie(c *gin.Context) {
	uid, err := c.Cookie("uid") //获取cookie值
	if err != nil {
		fmt.Println("cookie not exist")
	} else {
		fmt.Println("uid is", uid)
	}
	// 设置cookie
	c.SetCookie("name", uid, 3600, "/", "localhost", false, true)

}
